var gulp = require('gulp');
var imagemin = require('gulp-imagemin');
var clean = require('gulp-clean');
var gulpSequence = require('gulp-sequence');

gulp.task('clean', function () {
  return gulp.src('./dist/*', {read: false}).pipe(clean());
});

// 压缩图片
gulp.task('imgMin', () => {
  return gulp.src('./src/images/*.*')
    .pipe(imagemin())
    .pipe(gulp.dest('./dist/images/'))
});

gulp.task('CopyJs', function () {
  return gulp.src('./src/js/*.js').pipe(gulp.dest('./dist/js/'));
});

gulp.task('CopyStyle', function () {
  return gulp.src(['./src/style/*.css', '!./src/style/_*.css']).pipe(gulp.dest('./dist/style/'));
});

gulp.task('CopyHtml', function () {
  return gulp.src('./src/pug/*.html').pipe(gulp.dest('./dist/html/'));
});

gulp.task('default', gulpSequence('clean', 'CopyHtml', 'CopyStyle', 'CopyJs', 'imgMin'));
